package com.rpp.study.controller;

import com.rpp.study.base.LagouResponse;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description
 * @Author rpp
 * @Date 2020/8/30 11:24 下午
 */
@RestController
@RequestMapping("/config")
@RefreshScope
public class ConfigController {

    /**
     * 请求时间间隔
     */
    @Value("${user.request.timePeriod}")
    private Integer timePeriod;

    /**
     * 最大请求次数
     */
    @Value("${user.request.maxTimes}")
    private Integer maxTimes;

    /**
     * 查看配置信息
     *
     * @return
     */
    @GetMapping("/view")
    public LagouResponse viewConfig() {
        Map map = new HashMap(4);
        map.put("timePeriod", timePeriod);
        map.put("maxTimes", maxTimes);
        return LagouResponse.success(map);
    }
}
